#include <omp.h>

double integral_calc(const double param, Interval_t interval, size_t chunk, bool mode){
  double res = 0;
  double increase = (interval.sup - interval.inf) / (double) interval.increase_count;
  double init = interval.inf + 0.5 * increase;

#if !mode
  #pragma omp parallel for schedule(static, chunk) reduction (+:res)
#else
  #pragma omp parallel for schedule(dynamic, chunk) reduction (+:res)
#endif

  for(int i = 0; i < interval.increase_count; ++i){
    double x = init + i * increase;
    res += integrand(x, param); 
  }
  res *= increase;
  
  return res;
}
